

class NodeChooserThing < Thing
  attribute :content

  def recieve e
    if content = e.params[form_id(:node_identifier)]
      @content = content
    end
  end

  def creator e
    s = Element.new(:select, :name => (form_id :node_identifier))
    s << Element.new(:option, '--- nic ---', :value => '')
    Tree.instance.depth_first { |node|
      option = Element.new(:option, ("&nbsp;&nbsp;&nbsp;&nbsp;" * node.level) + node.title, :value => node.identity)
      if node.identity == content
        option.selected = "selected"
      end
      s << option
    }
    s.to_s
  end

  def render e
    ''
  end
end